<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QItemSelection Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QItemSelection Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QItemSelection class manages information about selected
items in a model. <a href="#details">More...</a></p>

<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qitemselection.html#QItemSelection">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qitemselection.html#QItemSelection-2">__init__</a></b> (<i>self</i>, QModelIndex&#160;<i>topLeft</i>, QModelIndex&#160;<i>bottomRight</i>)</li><li><div class="fn" /><b><a href="qitemselection.html#QItemSelection-3">__init__</a></b> (<i>self</i>, QItemSelection)</li><li><div class="fn" /><b><a href="qitemselection.html#append">append</a></b> (<i>self</i>, QItemSelectionRange&#160;<i>range</i>)</li><li><div class="fn" /><b><a href="qitemselection.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qitemselection.html#contains">contains</a></b> (<i>self</i>, QModelIndex&#160;<i>index</i>)</li><li><div class="fn" />int <b><a href="qitemselection.html#count">count</a></b> (<i>self</i>, QItemSelectionRange&#160;<i>range</i>)</li><li><div class="fn" />int <b><a href="qitemselection.html#count-2">count</a></b> (<i>self</i>)</li><li><div class="fn" />QItemSelectionRange <b><a href="qitemselection.html#first">first</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QModelIndex <b><a href="qitemselection.html#indexes">indexes</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qitemselection.html#indexOf">indexOf</a></b> (<i>self</i>, QItemSelectionRange&#160;<i>value</i>, int&#160;<i>from</i>&#160;=&#160;0)</li><li><div class="fn" /><b><a href="qitemselection.html#insert">insert</a></b> (<i>self</i>, int&#160;<i>i</i>, QItemSelectionRange&#160;<i>range</i>)</li><li><div class="fn" />bool <b><a href="qitemselection.html#isEmpty">isEmpty</a></b> (<i>self</i>)</li><li><div class="fn" />QItemSelectionRange <b><a href="qitemselection.html#last">last</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qitemselection.html#lastIndexOf">lastIndexOf</a></b> (<i>self</i>, QItemSelectionRange&#160;<i>value</i>, int&#160;<i>from</i>&#160;=&#160;-1)</li><li><div class="fn" /><b><a href="qitemselection.html#merge">merge</a></b> (<i>self</i>, QItemSelection&#160;<i>other</i>, QItemSelectionModel.SelectionFlags&#160;<i>command</i>)</li><li><div class="fn" /><b><a href="qitemselection.html#move">move</a></b> (<i>self</i>, int&#160;<i>from</i>, int&#160;<i>to</i>)</li><li><div class="fn" /><b><a href="qitemselection.html#prepend">prepend</a></b> (<i>self</i>, QItemSelectionRange&#160;<i>range</i>)</li><li><div class="fn" />int <b><a href="qitemselection.html#removeAll">removeAll</a></b> (<i>self</i>, QItemSelectionRange&#160;<i>range</i>)</li><li><div class="fn" /><b><a href="qitemselection.html#removeAt">removeAt</a></b> (<i>self</i>, int&#160;<i>i</i>)</li><li><div class="fn" /><b><a href="qitemselection.html#replace">replace</a></b> (<i>self</i>, int&#160;<i>i</i>, QItemSelectionRange&#160;<i>range</i>)</li><li><div class="fn" /><b><a href="qitemselection.html#select">select</a></b> (<i>self</i>, QModelIndex&#160;<i>topLeft</i>, QModelIndex&#160;<i>bottomRight</i>)</li><li><div class="fn" /><b><a href="qitemselection.html#swap">swap</a></b> (<i>self</i>, int&#160;<i>i</i>, int&#160;<i>j</i>)</li><li><div class="fn" />QItemSelectionRange <b><a href="qitemselection.html#takeAt">takeAt</a></b> (<i>self</i>, int&#160;<i>i</i>)</li><li><div class="fn" />QItemSelectionRange <b><a href="qitemselection.html#takeFirst">takeFirst</a></b> (<i>self</i>)</li><li><div class="fn" />QItemSelectionRange <b><a href="qitemselection.html#takeLast">takeLast</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" /><b><a href="qitemselection.html#split">split</a></b> (QItemSelectionRange&#160;<i>range</i>, QItemSelectionRange&#160;<i>other</i>, QItemSelection&#160;<i>result</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />int <b><a href="qitemselection.html#__contains__">__contains__</a></b> (<i>self</i>, QModelIndex&#160;<i>index</i>)</li><li><div class="fn" /><b><a href="qitemselection.html#__delitem__">__delitem__</a></b> (<i>self</i>, int&#160;<i>i</i>)</li><li><div class="fn" /><b><a href="qitemselection.html#__delitem__-2">__delitem__</a></b> (<i>self</i>, slice&#160;<i>slice</i>)</li><li><div class="fn" />bool <b><a href="qitemselection.html#__eq__">__eq__</a></b> (<i>self</i>, QItemSelection&#160;<i>other</i>)</li><li><div class="fn" />QItemSelectionRange <b><a href="qitemselection.html#__getitem__">__getitem__</a></b> (<i>self</i>, int&#160;<i>i</i>)</li><li><div class="fn" />QItemSelection <b><a href="qitemselection.html#__getitem__-2">__getitem__</a></b> (<i>self</i>, slice&#160;<i>slice</i>)</li><li><div class="fn" />QItemSelection <b><a href="qitemselection.html#__iadd__">__iadd__</a></b> (<i>self</i>, QItemSelection&#160;<i>other</i>)</li><li><div class="fn" />QItemSelection <b><a href="qitemselection.html#__iadd__-2">__iadd__</a></b> (<i>self</i>, QItemSelectionRange&#160;<i>value</i>)</li><li><div class="fn" /> <b><a href="qitemselection.html#__len__">__len__</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qitemselection.html#__ne__">__ne__</a></b> (<i>self</i>, QItemSelection&#160;<i>other</i>)</li><li><div class="fn" /><b><a href="qitemselection.html#__setitem__">__setitem__</a></b> (<i>self</i>, int&#160;<i>i</i>, QItemSelectionRange&#160;<i>range</i>)</li><li><div class="fn" /><b><a href="qitemselection.html#__setitem__-2">__setitem__</a></b> (<i>self</i>, slice&#160;<i>slice</i>, QItemSelection&#160;<i>list</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QItemSelection class manages information about selected
items in a model.</p>
<p>A QItemSelection describes the items in a model that have been
selected by the user. A QItemSelection is basically a list of
selection ranges, see <a href="qitemselectionrange.html">QItemSelectionRange</a>. It provides
functions for creating and manipulating selections, and selecting a
range of items from a model.</p>
<p>The QItemSelection class is one of the <a href="model-view.html">Model/View Classes</a> and is part of Qt's
<a href="model-view-programming.html">model/view framework</a>.</p>
<p>An item selection can be constructed and initialized to contain
a range of items from an existing model. The following example
constructs a selection that contains a range of items from the
given <tt>model</tt>, beginning at the <tt>topLeft</tt>, and ending
at the <tt>bottomRight</tt>.</p>
<pre class="cpp">
 <span class="type">QItemSelection</span> <span class="operator">*</span>selection <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QItemSelection</span>(topLeft<span class="operator">,</span> bottomRight);
</pre>
<p>An empty item selection can be constructed, and later populated
as required. So, if the model is going to be unavailable when we
construct the item selection, we can rewrite the above code in the
following way:</p>
<pre class="cpp">
 <span class="type">QItemSelection</span> <span class="operator">*</span>selection <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QItemSelection</span>();
 <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
 selection<span class="operator">-</span><span class="operator">&gt;</span><a href="qitemselection.html#select">select</a>(topLeft<span class="operator">,</span> bottomRight);
</pre>
<p>QItemSelection saves memory, and avoids unnecessary work, by
working with selection ranges rather than recording the model item
index for each item in the selection. Generally, an instance of
this class will contain a list of non-overlapping selection
ranges.</p>
<p>Use <a href="qitemselection.html#merge">merge</a>() to merge one
item selection into another without making overlapping ranges. Use
<a href="qitemselection.html#split">split</a>() to split one
selection range into smaller ranges based on a another selection
range.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QItemSelection" />QItemSelection.__init__ (<i>self</i>)</h3><p>Constructs an empty selection.</p>


<h3 class="fn"><a name="QItemSelection-2" />QItemSelection.__init__ (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>topLeft</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>bottomRight</i>)</h3><p>Constructs an item selection that extends from the top-left
model item, specified by the <i>topLeft</i> index, to the
bottom-right item, specified by <i>bottomRight</i>.</p>


<h3 class="fn"><a name="QItemSelection-3" />QItemSelection.__init__ (<i>self</i>, <a href="qitemselection.html">QItemSelection</a>)</h3><h3 class="fn"><a name="append" />QItemSelection.append (<i>self</i>, <a href="qitemselectionrange.html">QItemSelectionRange</a>&#160;<i>range</i>)</h3><h3 class="fn"><a name="clear" />QItemSelection.clear (<i>self</i>)</h3><h3 class="fn"><a name="contains" />bool QItemSelection.contains (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>index</i>)</h3><p>Returns true if the selection contains the given <i>index</i>;
otherwise returns false.</p>


<h3 class="fn"><a name="count" />int QItemSelection.count (<i>self</i>, <a href="qitemselectionrange.html">QItemSelectionRange</a>&#160;<i>range</i>)</h3><h3 class="fn"><a name="count-2" />int QItemSelection.count (<i>self</i>)</h3><h3 class="fn"><a name="first" /><a href="qitemselectionrange.html">QItemSelectionRange</a> QItemSelection.first (<i>self</i>)</h3><h3 class="fn"><a name="indexes" />list-of-QModelIndex QItemSelection.indexes (<i>self</i>)</h3><p>Returns a list of model indexes that correspond to the selected
items.</p>


<h3 class="fn"><a name="indexOf" />int QItemSelection.indexOf (<i>self</i>, <a href="qitemselectionrange.html">QItemSelectionRange</a>&#160;<i>value</i>, int&#160;<i>from</i>&#160;=&#160;0)</h3><h3 class="fn"><a name="insert" />QItemSelection.insert (<i>self</i>, int&#160;<i>i</i>, <a href="qitemselectionrange.html">QItemSelectionRange</a>&#160;<i>range</i>)</h3><h3 class="fn"><a name="isEmpty" />bool QItemSelection.isEmpty (<i>self</i>)</h3><h3 class="fn"><a name="last" /><a href="qitemselectionrange.html">QItemSelectionRange</a> QItemSelection.last (<i>self</i>)</h3><h3 class="fn"><a name="lastIndexOf" />int QItemSelection.lastIndexOf (<i>self</i>, <a href="qitemselectionrange.html">QItemSelectionRange</a>&#160;<i>value</i>, int&#160;<i>from</i>&#160;=&#160;-1)</h3><h3 class="fn"><a name="merge" />QItemSelection.merge (<i>self</i>, <a href="qitemselection.html">QItemSelection</a>&#160;<i>other</i>, <a href="qitemselectionmodel-selectionflags.html">QItemSelectionModel.SelectionFlags</a>&#160;<i>command</i>)</h3><p>Merges the <i>other</i> selection with this <a href="qitemselection.html">QItemSelection</a> using the <i>command</i>
given. This method guarantees that no ranges are overlapping.</p>
<p>Note that only <a href="qitemselectionmodel.html#SelectionFlag-enum">QItemSelectionModel.Select</a>,
<a href="qitemselectionmodel.html#SelectionFlag-enum">QItemSelectionModel.Deselect</a>,
and <a href="qitemselectionmodel.html#SelectionFlag-enum">QItemSelectionModel.Toggle</a>
are supported.</p>
<p><b>See also</b> <a href="qitemselection.html#split">split</a>().</p>


<h3 class="fn"><a name="move" />QItemSelection.move (<i>self</i>, int&#160;<i>from</i>, int&#160;<i>to</i>)</h3><h3 class="fn"><a name="prepend" />QItemSelection.prepend (<i>self</i>, <a href="qitemselectionrange.html">QItemSelectionRange</a>&#160;<i>range</i>)</h3><h3 class="fn"><a name="removeAll" />int QItemSelection.removeAll (<i>self</i>, <a href="qitemselectionrange.html">QItemSelectionRange</a>&#160;<i>range</i>)</h3><h3 class="fn"><a name="removeAt" />QItemSelection.removeAt (<i>self</i>, int&#160;<i>i</i>)</h3><h3 class="fn"><a name="replace" />QItemSelection.replace (<i>self</i>, int&#160;<i>i</i>, <a href="qitemselectionrange.html">QItemSelectionRange</a>&#160;<i>range</i>)</h3><h3 class="fn"><a name="select" />QItemSelection.select (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>topLeft</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>bottomRight</i>)</h3><p>Adds the items in the range that extends from the top-left model
item, specified by the <i>topLeft</i> index, to the bottom-right
item, specified by <i>bottomRight</i> to the list.</p>
<p><b>Note:</b> <i>topLeft</i> and <i>bottomRight</i> must have the
same parent.</p>


<h3 class="fn"><a name="split" />QItemSelection.split (<a href="qitemselectionrange.html">QItemSelectionRange</a>&#160;<i>range</i>, <a href="qitemselectionrange.html">QItemSelectionRange</a>&#160;<i>other</i>, <a href="qitemselection.html">QItemSelection</a>&#160;<i>result</i>)</h3><p>Splits the selection <i>range</i> using the selection
<i>other</i> range. Removes all items in <i>other</i> from
<i>range</i> and puts the result in <i>result</i>. This can be
compared with the semantics of the <i>subtract</i> operation of a
set.</p>
<p><b>See also</b> <a href="qitemselection.html#merge">merge</a>().</p>
<h3 class="fn"><a name="swap" />QItemSelection.swap (<i>self</i>, int&#160;<i>i</i>, int&#160;<i>j</i>)</h3><h3 class="fn"><a name="takeAt" /><a href="qitemselectionrange.html">QItemSelectionRange</a> QItemSelection.takeAt (<i>self</i>, int&#160;<i>i</i>)</h3><h3 class="fn"><a name="takeFirst" /><a href="qitemselectionrange.html">QItemSelectionRange</a> QItemSelection.takeFirst (<i>self</i>)</h3><h3 class="fn"><a name="takeLast" /><a href="qitemselectionrange.html">QItemSelectionRange</a> QItemSelection.takeLast (<i>self</i>)</h3><h3 class="fn"><a name="__contains__" />int QItemSelection.__contains__ (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>index</i>)</h3><h3 class="fn"><a name="__delitem__" />QItemSelection.__delitem__ (<i>self</i>, int&#160;<i>i</i>)</h3><h3 class="fn"><a name="__delitem__-2" />QItemSelection.__delitem__ (<i>self</i>, slice&#160;<i>slice</i>)</h3><h3 class="fn"><a name="__eq__" />bool QItemSelection.__eq__ (<i>self</i>, <a href="qitemselection.html">QItemSelection</a>&#160;<i>other</i>)</h3><h3 class="fn"><a name="__getitem__" /><a href="qitemselectionrange.html">QItemSelectionRange</a> QItemSelection.__getitem__ (<i>self</i>, int&#160;<i>i</i>)</h3><h3 class="fn"><a name="__getitem__-2" /><a href="qitemselection.html">QItemSelection</a> QItemSelection.__getitem__ (<i>self</i>, slice&#160;<i>slice</i>)</h3><h3 class="fn"><a name="__iadd__" /><a href="qitemselection.html">QItemSelection</a> QItemSelection.__iadd__ (<i>self</i>, <a href="qitemselection.html">QItemSelection</a>&#160;<i>other</i>)</h3><h3 class="fn"><a name="__iadd__-2" /><a href="qitemselection.html">QItemSelection</a> QItemSelection.__iadd__ (<i>self</i>, <a href="qitemselectionrange.html">QItemSelectionRange</a>&#160;<i>value</i>)</h3><h3 class="fn"><a name="__len__" /> QItemSelection.__len__ (<i>self</i>)</h3><h3 class="fn"><a name="__ne__" />bool QItemSelection.__ne__ (<i>self</i>, <a href="qitemselection.html">QItemSelection</a>&#160;<i>other</i>)</h3><h3 class="fn"><a name="__setitem__" />QItemSelection.__setitem__ (<i>self</i>, int&#160;<i>i</i>, <a href="qitemselectionrange.html">QItemSelectionRange</a>&#160;<i>range</i>)</h3><h3 class="fn"><a name="__setitem__-2" />QItemSelection.__setitem__ (<i>self</i>, slice&#160;<i>slice</i>, <a href="qitemselection.html">QItemSelection</a>&#160;<i>list</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.9.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2011</td><td align="right" width="25%">Qt&#160;4.8.0</td></tr></table></div></address></body></html>